Page({
  data: {
    deviceName: "",
  },
  onLoad: function () {
  },
  onShow: function () {
  },
 
  /* 点击事件 */
  click: function (event) { 
    var that = this;
    //调用扫码功能
    wx.scanCode({
      success: (res) => {
        console.log(res)
        that.setData({
          deviceName: res.result
        })
        //获取到二维码中的蓝牙设备名后跳转到连接页面
              var title = that.data.deviceName;
              wx.redirectTo({
                url: '../control/control?id=' + title
              })   
      },
      fail: (res) => {
        wx.showToast({
          title: '扫码失败',
          icon: 'error',
          duration: 2000
        })
      },
    })  
  },
})

